﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Services;
namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 通用违章性质管理
/// </summary>
[Route("QHSEGeneralDanger/[action]")]
[ApiController]

public class QHSEGeneralDangerController : ControllerBase
{
    private readonly QHSEGeneralDangerService _generalDangerService;

    public QHSEGeneralDangerController(QHSEGeneralDangerService generalDangerService)
    {
        _generalDangerService = generalDangerService;
    }

    /// <summary>
    /// 通用隐患性质列表
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> List()
    {
        List<QHSEGeneralDangerModel> data = await _generalDangerService.GetAsync();
        return AppResult.Status200OK(data: data);
    }

    /// <summary>
    /// 通用隐患条款查询
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> ClausePage([FromQuery] GeneralDangerInputModel input)
    {
        PageResultModel<QHSEGeneralDangerModel> data = await _generalDangerService.QueryByViolationTypeCodeAsync(input);
        return AppResult.Status200OK(data: data);
    }

}

